<?php
class ModelFaPurchaseOrder extends Model {
    public function getPurchase($supplier_id){
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "fa_purchase_price WHERE supplier_id = '" . (int)$supplier_id . "'");
        //print_r($query);        exit();
        return $query->rows;        
    }
    
    public function getItem($item_id) {
        $query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'item_id=" . (int) $item_id . "') AS keyword FROM " . DB_PREFIX . "fa_item p LEFT JOIN " . DB_PREFIX . "fa_item_description pd ON (p.item_id = pd.item_id) WHERE p.item_id = '" . (int) $item_id . "' AND pd.language_id = '" . (int) $this->config->get('config_language_id') . "'");

        return $query->row;
    }
    
    public function getItems($item_id) {
        $sql = "SELECT * FROM " . DB_PREFIX . "fa_item p LEFT JOIN " . DB_PREFIX . "fa_item_description pd ON (p.item_id = pd.item_id)";
        
        $sql .= " WHERE pd.language_id = '" . (int) $this->config->get('config_language_id') . "'";
        
        //$sql .= " AND p.item_id = " . (int)$item_id;
        
        $sql .= " GROUP BY p.item_id";
        
        $query = $this->db->query($sql);
        
        $item_info = $query->rows;
        
        return $item_info;
    }
}
?>
